package algorithms;


import base.Chromosome;
import base.Population;

public class TournamentSelection extends Selection {

	public TournamentSelection(Population chromes) {
		super(chromes);
		
	}

	//select 7 random chromes and then select the best
	@Override
	public Chromosome Select() {
		Chromosome[] randList = new Chromosome[7];
		for (int i = 0; i < 7; i++) {
			randList[i] = _chromes.GetRandomChromosome();
		}
		Chromosome best = randList[0];
		for (int i = 1; i < 7; i++) {
			if (randList[i].get_fitness() < best.get_fitness())
				best = randList[i];
		}
		return best;
	}

}
